#! /bin/sh
# shell for running unif2 --- uniformly sampled Cshot model
# data is smoothed with smo2d
set -x

input=lens_t_1st.dat
outps=t_1st.ps
out1=junk1.b
out2=junk2.b
out3=junk3.b

d1=0.05 d2=0.05

n1=61 n2=11 n3=101

id1s=1 if1s=0  n1s=61
id2s=1 if2s=5  n2s=1
id3s=1 if3s=0  n3s=101

a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
pscontour<$out2 n1=$n1s d1=$d1 d2=$d2 dc=0.05 nc=40 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Travel time (first arrival)">$outps

input=lens_amp_1st.dat
outps=amp_1st.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
farith<$out2 op=log |farith op=neg >$out3
pscontour<$out3 n1=$n1s d1=$d1 d2=$d2 nc=30 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Amplitude -log (first arrival)">$outps

input=lens_pha_1st.dat
outps=pha_1st.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
psimage<$out2 n1=$n1s d1=$d1 d2=$d2 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Phase-shift (first arrival)">$outps


input=lens_t_2nd.dat
outps=t_2nd.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
pscontour<$out2 n1=$n1s d1=$d1 d2=$d2 dc=0.05 nc=40 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Travel time (second arrival)">$outps

input=lens_amp_2nd.dat
outps=amp_2nd.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
farith<$out2 op=log |farith op=neg >$out3
pscontour<$out3 n1=$n1s d1=$d1 d2=$d2 nc=30 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Amplitude -log (second arrival)">$outps

input=lens_pha_2nd.dat
outps=pha_2nd.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
psimage<$out2 n1=$n1s d1=$d1 d2=$d2 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Phase-shift (second arrival)">$outps


input=lens_t_3rd.dat
outps=t_3rd.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
pscontour<$out2 n1=$n1s d1=$d1 d2=$d2 dc=0.05 nc=40 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Travel time (third arrival)">$outps

input=lens_amp_3rd.dat
outps=amp_3rd.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
farith<$out2 op=log |farith op=neg >$out3
pscontour<$out3 n1=$n1s d1=$d1 d2=$d2 nc=30 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Amplitude -log (third arrival)">$outps

input=lens_pha_3rd.dat
outps=pha_3rd.ps
a2b<$input n1=1>$out1
subset<$out1 n1=$n1 n2=$n2 n3=$n3 \
              id1s=$id1s if1s=$if1s n1s=$n1s\
              id2s=$id2s if2s=$if2s n2s=$n2s\
              id3s=$id3s if3s=$if3s n3s=$n3s>$out2
psimage<$out2 n1=$n1s d1=$d1 d2=$d2 hbox=5.0\
	label1="Z (km)" label2="X (km)" \
	title="Phase-shift (third arrival)">$outps


rm -f $out1 $out2 $out3
exit 0
